import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
    VillageAcceessCardState state, Dispatch dispatch, ViewService viewService) {
  return ListView.builder(
    itemCount: state.cardList.length,
    itemBuilder: (ctx, position) {
      var cardInfo = state.cardList[position];
      var title = cardInfo.cardType == 'DOORCARD'
          ? '${cardInfo.buildingCode}-${cardInfo.itemCode}-${cardInfo.roomCode} ${cardInfo.ownerName}'
          : '管理卡';
      return ListTile(
        title: Text(title),
        subtitle:
            Text('卡号:${cardInfo.cardNo} ${cardInfo.useStatusDesc}(有效期至：${cardInfo.endTimeDesc})'),
        trailing: IconButton(
          icon: Icon(Icons.edit),
          onPressed: () {},
        ),
      );
    },
  );
}
